#ifndef YHAIDA_HTTPCONTEXT_H
#define YHAIDA_HTTPCONTEXT_H

#include "HttpRequest.h"

namespace yhaida
{
    class HttpContext
    {
    public:
        HttpContext();
        ~HttpContext() = default;
        bool parseRequest(Buffer *buffer, Timestamp receiveTime);
        bool gotAll() const;
        void reset();
        const HttpRequest &request() const;
        HttpRequest &request();

    public:
        enum HttpRequestParseState
        {
            kExpectRequestLine,
            kExpectHeaders,
            kExpectBody,
            kGotAll,
        };

    private:
        bool processRequestLine(const char *begin, const char *end);

    private:
        HttpRequestParseState _state;
        HttpRequest _request;
    };
}

#endif
